<template>
	<view class="equipment">
		<view class="head" :style="{height: pHeight + tHeight + 'px'}">
			<view class="xztitle" :style="[{height: pHeight + 'px', top: tHeight + 'px',lineHeight: pHeight + 'px'}]">
				设备下拨记录
				<view class="iconfont icon-dayuhao1" @click="fanhui"></view>
			</view>
		</view>
		<view class="headtop" :style="{marginTop: pHeight + tHeight + 'px'}">
			<view class="center">
				<view class="sousuo">
					<input type="text" placeholder="请输入关键字" v-model="keywords" />
					<image :src="baseUrl + '/wximage/sousuo.png'"></image>
				</view>
			</view>
		</view>
		<view class="morebeijing" v-if="morebjstatus" @click="guanbi"></view>
		<view class="moretankuang" v-if="morestatus">
			<view class="bankuai">
				<view class="top">时间选择</view>
				<view class="time">
					<text>{{sdate}}</text>至<text>{{edate}}</text>
				</view>
				<view class="bottom clearfix">
					<text @click="show = true">开始时间</text>
					<text @click="show = true">结束时间</text>
				</view>
				<u-calendar v-model="show" :mode="mode" toolTip="时间选择" @change="change"></u-calendar>
			</view>
			<view class="bankuai">
				<view class="top">会员卡状态</view>
				<view class="bottom clearfix">
					<text class="active">全部</text>
					<text>已发放</text>
					<text>已失效</text>
				</view>
			</view>
			<view class="bankuai">
				<view class="top">会员卡类型</view>
				<view class="bottom bottomts clearfix">
					<text class="active">全部</text>
					<text>月卡</text>
					<text>季卡</text>
					<text>年卡</text>
					<text>两年卡</text>
					<text>三年卡</text>
					<text>付费会员卡</text>
				</view>
			</view>
			<view class="queren">
				确认
			</view>
		</view>
		<view class="content" v-if="list.length != 0">
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="top clearfix">
					<view class="title fl">设备SN：{{item.sn}}</view>
					<view class="money fr" v-if="item.attr==1">选中下拨</view>
					<view class="money fr" v-else>选中下拨</view>
				</view>
				<view class="center">
					<view class="desc">商户名称：<text class="color">{{item.bussiness_name}}</text></view>
					<!-- <view class="desc">会员ID：</view> -->
					<view class="desc">操作时间：{{item.create_at}}</view>
				</view>
			</view>
			
			<!-- <view class="list">
				<view class="top clearfix">
					<view class="title fl">设备SN：8363837363387</view>
					<view class="money fr">扫码下拨</view>
				</view>
				<view class="center">
					<view class="desc">商户名称：<text class="color">测试商户</text></view>
					<view class="desc">会员ID：</view>
					<view class="desc">操作时间：2024-07-15 12:14:47</view>
				</view>
			</view> -->
		</view>
		<view class="empty" v-else>
			<image :src="baseUrl + '/wximage/empty.png'"></image>
			<text>暂无相关数据</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: getApp().globalData.baseUrl,
				headerTop: 0,
				pHeight: 0,
				tHeight: 0,
				keywords: '',
				list: [],
				morebjstatus: false,
				morestatus: false,
				show: false,
				mode: 'range',
				sdate: '--',
				edate: '--',
				formData:{
					agent_id: uni.getStorageSync('agent_id'),
					page: 1,
					pageSize: 30,
					search: ''
				}
			}
		},
		onLoad() {
			// 头部距离
			let res = uni.getSystemInfoSync() ///微信api方法
			let titleH;
			if (res && res['system']) {
				// 判断是否是安卓操作系统 （标题栏苹果为44px,安卓为48px）
				if (res['system'].indexOf('Android') > 0) {
					titleH = 48
				} else {
					titleH = 46
				}
				this.headerTop = titleH + res['statusBarHeight']
				this.pHeight = titleH
				this.tHeight = res['statusBarHeight']
			}
			this.formList();
		},
		methods: {
			formList(){
						this.request({
							url: '/wxdevice/allocatedlog',
							data: this.formData,
							method: "GET"
						}).then(res => {
							if (res.data.code == 200) {
								// console.log(res);
								if(res.data.data.list.length!=0){
									this.list = res.data.data.list;
									// this.bussinessList = this.bussinessList.concat(res.data.data);
								}
							} else {
								uni.showToast({
									title: res.data.message,
									icon: 'none'
								})
							}
						});
			},
			shaixuan(){
				this.morebjstatus = !this.morebjstatus;
				this.morestatus = !this.morestatus;
			},
			guanbi(){
				this.morebjstatus = false;
				this.morestatus = false;
			},
			change(e) {
				this.sdate = e.startDate;
				this.edate = e.endDate;
			},
			fanhui() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.equipment {
		width: 100%;
		margin: 0 auto;
		height: 100vh;
		background: #f9f9ff;
		overflow-y: scroll;

		.head {
			width: 100%;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);

			.xztitle {
				position: fixed;
				left: 0%;
				top: 0;
				width: 100%;
				text-align: left;
				color: #333333;
				font-size: 32rpx;
				padding-left: 74rpx;
				font-weight: 700;

				text {
					font-size: 24rpx;
				}

				.iconfont {
					position: absolute;
					top: 0;
					left: 30rpx;
					font-size: 44rpx;
				}
			}
		}

		.headtop {
			width: 100%;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);
			height: 300rpx;
			padding: 20rpx 20rpx 0;
			box-sizing: border-box;
			
			.center{
				width: 100%;
				padding: 0 20rpx;
				box-sizing: border-box;
				
				.sousuo {
					width: 100%;
					box-sizing: border-box;
					position: relative;
						
					input {
						width: 100%;
						height: 60rpx;
						line-height: 60rpx;
						background: #ffffff;
						border-radius: 30rpx;
						padding-left: 30rpx;
						color: #999999;
						box-sizing: border-box;
					}
						
					image {
						width: 72rpx;
						height: 40rpx;
						position: absolute;
						right: 10rpx;
						top: 10rpx;
					}
				}
			}
		}
		
		.content{
			width: 100%;
			padding: 0 40rpx;
			box-sizing: border-box;
			margin-top: -180rpx;
			position: absolute;
			
			.list{
				width: 100%;
				background: #fff;
				border-radius: 20rpx;
				margin-bottom: 20rpx;
				padding: 26rpx;
				box-shadow: rgba(223, 230, 255, 0.67) 0px 0px 6px;
				
				.top{
					width: 100%;
					border-bottom: 1rpx solid #F1F1F1;
					padding-bottom: 20rpx;
					
					.title{
						font-size: 28rpx;
						color: #333333;
						font-weight: 700;
					}
					
					.money{
						font-size: 28rpx;
						color: #8B8CFF;
						margin-right: 8rpx;
						font-weight: 700;
					}
				}
				
				.center{
					width: 96%;
					margin: 0 auto;
					margin-top: 20rpx;
					
					.desc{
						width: 90%;
						font-size: 24rpx;
						color: #333333;
						line-height: 44rpx;
					}
					
					.color{
						font-size: 24rpx;
						color: #5C88FA;
					}
				}
			}
		}
		
		.empty{
			width: 100%;
			margin: 200rpx auto 0;
			text-align: center;
			
			image{
				width: 390rpx;
				height: 340rpx;
			}
			
			text{
				display: block;
				margin-top: 60rpx;
				font-size: 24rpx;
				color: #666666;
			}
		}
		
		.morebeijing{
			position: absolute;
			bottom: 0;
			left: 0;
			width: 100%;
			height: 100vh;
			background: #000000;
			opacity: 0.5;
			z-index: 100;
		}
		
		.moretankuang{
			position: absolute;
			bottom: 0;
			left: 0;
			width: 100%;
			height: 1000rpx;
			background: #fff;
			z-index: 200;
			border-top-left-radius: 20rpx;
			border-top-right-radius: 20rpx;
			padding: 20rpx 0;
			
			.bankuai{
				
				.top{
					background: #FDFDFD;
					font-size: 32rpx;
					color: #333333;
					height: 72rpx;
					line-height: 72rpx;
					padding-left: 40rpx;
					box-sizing: border-box;
					border-bottom: 1rpx solid #DFE6FF;
				}
				
				.time{
					margin-top: 20rpx;
					margin-left: 40rpx;
					font-size: 24rpx;
					color: #333333;
					
					text:nth-of-type(1){
						font-size: 24rpx;
						color: #FA5E5C;
					}
					
					text:nth-of-type(2){
						font-size: 24rpx;
						color: #5C88FA;
					}
				}
				
				.bottom{
					margin-top: 40rpx;
					margin-bottom: 50rpx;
					
					text{
						display: inline-block;
						margin-left: 60rpx;
						width: 160rpx;
						height: 54rpx;
						text-align: center;
						border-radius: 16rpx;
						line-height: 54rpx;
						background: #F6F6F6;
						font-size: 24rpx;
						color: #333333;
					}
					
					.active{
						background: #E3F2FF;
					}
				}
				
				.bottomts{
					
					text{
						margin-bottom: 20rpx;
					}
				}
			}
			
			.queren{
				width: 180rpx;
				margin: 0 auto;
				height: 60rpx;
				line-height: 60rpx;
				border-radius: 16rpx;
				text-align: center;
				background: #3B91F8;
				margin-top: 30rpx;
				font-size: 28rpx;
				color: #FFFFFF;
			}
		}
		
		.beijing{
			position: absolute;
			top: 250rpx;
			left: 0;
			width: 100%;
			height: 78vh;
			background: #000000;
			opacity: 0.5;
			z-index: 100;
		}
		
		.tankuang{
			position: absolute;
			top: 250rpx;
			left: 0;
			width: 100%;
			height: 400rpx;
			background: #fff;
			overflow-y: scroll;
			z-index: 200;
			border-bottom-left-radius: 20rpx;
			border-bottom-right-radius: 20rpx;
			padding: 20rpx 0;
			
			.liebiao{
				width: 100%;
				height: 72rpx;
				line-height: 72rpx;
				text-align: center;
				position: relative;
				
				.wenzi{
					font-size: 24rpx;
					color: #999999;
				}
				
				image{
					width: 100%;
					height: 72rpx;
					position: absolute;
					top: 0;
					left: 0;
				}
			}
		}
	}
</style>